package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.SystemDictionary;
import cn.wolfcode.crm.mapper.SystemDictionaryMapper;
import cn.wolfcode.crm.service.ISystemDictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemDictionaryServiceImpl implements ISystemDictionaryService {

    @Autowired
    private SystemDictionaryMapper systemDictionaryMapper;

    public void saveOrUpdate(SystemDictionary entity) {
        if(entity.getId() != null){
            systemDictionaryMapper.updateByPrimaryKey(entity);
        } else {
            systemDictionaryMapper.insert(entity);
        }
    }

    public void delete(Long id) {
        systemDictionaryMapper.deleteByPrimaryKey(id);
    }

    public SystemDictionary get(Long id) {
        if(id != null) {
            return systemDictionaryMapper.selectByPrimaryKey(id);
        }
        return null;
    }

    public List<SystemDictionary> list() {
        return systemDictionaryMapper.selectAll();
    }

}
